package com.qf.shopping.service.impl;

import com.qf.shopping.dto.memberDTO.MemberPointDTO;
import com.qf.shopping.mapper.IMemberMapper;

import com.qf.shopping.dto.memberDTO.MemberDTO;
import com.qf.shopping.dto.memberDTO.MemberProfileDTO;
import com.qf.shopping.pojo.member.MemberCar;
import com.qf.shopping.pojo.member.MemberPoint;
import com.qf.shopping.pojo.member.MemberProfile;
import com.qf.shopping.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.xml.bind.SchemaOutputResolver;
import java.util.ArrayList;
import java.util.List;
/*
    会员业务层
 */

@Service
@Transactional
public class MemberServiceImpl implements MemberService{

    @Autowired
    private IMemberMapper iMemberMapper=null;



    @Override
    public MemberProfileDTO getMerberProfile(long id) {
        MemberProfile memberProfile=iMemberMapper.findMemberProfileById(id);
        MemberProfileDTO memberProfileDTO=new MemberProfileDTO(memberProfile);
        return memberProfileDTO;
    }


    @Override
    public List<MemberDTO> getMemberList() {
        List<MemberProfile> listpo=iMemberMapper.findByAllMemberProfile();
        List<MemberDTO> listdao=new ArrayList<>();
        for (MemberProfile m:listpo) {
            listdao.add(new MemberDTO(m));
        }
        return listdao;
    }



    @Override
    public List<MemberProfile> findByMemberLikeusername(MemberProfile memberProfile) {
        return null;
    }

    @Override
    public MemberProfile findMemberProfileById(long id) {
        return null;
    }

    @Override
    public MemberCar findMemberCarById(long memberId) {


        return null;
    }

    //会员积分功能
    @Override
    public List<MemberPointDTO> getMemberPointById(long memberId) {
        List<MemberPointDTO> listDTO=new ArrayList<>();
        List<MemberPoint> list=iMemberMapper.findMemberPointById(1);
        if(list !=null){
            for (MemberPoint m:list) {
                listDTO.add(new MemberPointDTO(m));
            }
            return listDTO;
        }
       return null;
    }

}
